//
//  DeviceSearchCell.m
//  Romens.XSBalance
//
//  Created by 李美东 on 16/2/24.
//  Copyright © 2016年 孙博. All rights reserved.
//

#import "DeviceSearchCell.h"
#import "ToolHelper.h"
@implementation DeviceSearchCell
-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self=[super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self)
    {
        _ScalageImage=[[UIImageView alloc]init];
        _ScalageImage.image=[UIImage imageNamed:@"scalage"];
        _ScalageImage.translatesAutoresizingMaskIntoConstraints=NO;
        [self.contentView addSubview:_ScalageImage];
        
        _Name=[[UILabel alloc]init];
        _Name.translatesAutoresizingMaskIntoConstraints=NO;
        _Name.font=systemDefaultFont;
        _Name.textColor=[UIColor blackColor];
        [self.contentView addSubview:_Name];
        
        _SerialNO=[[UILabel alloc]init];
        _SerialNO.translatesAutoresizingMaskIntoConstraints=NO;
        _SerialNO.font=systemDetailFont;
        _SerialNO.textColor=[UIColor grayColor];
        _SerialNO.numberOfLines=2;
        [self.contentView addSubview:_SerialNO];
        
        _IndicateLight=[[F3BarGauge alloc]init];
        _IndicateLight.translatesAutoresizingMaskIntoConstraints=NO;
        _IndicateLight.numBars=20;
        [self.contentView addSubview:_IndicateLight];
        
        [self.contentView addConstraints:[ToolHelper GetNSLayoutCont:NSDictionaryOfVariableBindings(_ScalageImage,_Name,_IndicateLight) format:@"H:|-10-[_ScalageImage(40)]-8-[_Name(100)]-10-[_IndicateLight]-8-|"]];
        [self.contentView addConstraints:[ToolHelper GetNSLayoutCont:NSDictionaryOfVariableBindings(_ScalageImage,_SerialNO) format:@"H:|-10-[_ScalageImage]-8-[_SerialNO]|"]];
        [self.contentView addConstraints:[ToolHelper GetNSLayoutCont:NSDictionaryOfVariableBindings(_ScalageImage) format:@"V:[_ScalageImage(40)]"]];
        [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:_ScalageImage
                                                                     attribute:NSLayoutAttributeCenterY
                                                                     relatedBy:NSLayoutRelationEqual
                                                                        toItem:self.contentView                                                    attribute:NSLayoutAttributeCenterY
                                                                    multiplier:1.0f
                                                                      constant:0]];
        [self.contentView addConstraints:[ToolHelper GetNSLayoutCont:NSDictionaryOfVariableBindings(_Name,_SerialNO) format:@"V:|-10-[_Name(20)]-1-[_SerialNO]-10-|"]];
        
        [self.contentView addConstraints:[ToolHelper GetNSLayoutCont:NSDictionaryOfVariableBindings(_IndicateLight) format:@"V:[_IndicateLight(20)]"]];
        
        [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:_IndicateLight
                                                                     attribute:NSLayoutAttributeCenterY
                                                                     relatedBy:NSLayoutRelationEqual
                                                                        toItem:_Name                                                    attribute:NSLayoutAttributeCenterY
                                                                    multiplier:1.0f
                                                                      constant:0]];
        
    }
    return self;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
